package xuegao.study.mall.admin.feign;

import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import xuegao.study.mall.common.api.CommonPage;
import xuegao.study.mall.common.api.CommonResult;
import xuegao.study.mall.common.model.ums.UmsResource;
import xuegao.study.mall.common.model.ums.UmsResourceCategory;

import java.util.List;

@FeignClient(contextId = "resource", name = "study-rbac-service", path = "/rbac/resource")
public interface UmsResourceClient {

    @ApiOperation("添加资源")
    @PostMapping("/create")
    CommonResult<Integer> add(@RequestBody UmsResource umsResource);

    @ApiOperation("删除资源")
    @DeleteMapping("/delete/{id}")
    CommonResult<Integer> deleteResource(@PathVariable("id") Long id);

    @ApiOperation("更新资源")
    @PostMapping("/update/{id}")
    CommonResult<Integer> update(@PathVariable("id") Long id, @RequestBody UmsResource umsResource);

    @ApiOperation("查询所有资源")
    @GetMapping("/listAll")
    CommonResult<List<UmsResource>> listAll();

    @ApiOperation("分页查询资源")
    @GetMapping("/list")
    CommonResult<CommonPage<UmsResource>> listResource(
            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
            @RequestParam(value = "nameKeyword", defaultValue = "") String nameKeyword,
            @RequestParam(value = "urlKeyword", defaultValue = "") String urlKeyword,
            @RequestParam(value = "categoryId", required = false) Long categoryId);

    @ApiOperation("查询资源目录")
    @GetMapping("/resourceCategory/listAll")
    CommonResult<List<UmsResourceCategory>> listMenu();
}
